﻿/**
 * 內存釋放
 * @author lmzd
 */
package com.kucooler.common.utils {
	import flash.system.System;
	import flash.net.LocalConnection;
	import com.kucooler.fog.utils.PaperLogger;
	
	public class DestroyMemory
	{
		
		public function DestroyMemory() 
		{
			return;
		}
		/**
		 * 強制內存回收
		 */
		public static function clear() {
			var _totalMemory:uint = System.totalMemory;
			try {
				new LocalConnection().connect("foo");
				new LocalConnection().connect("foo");
			}catch (e:Error) {				
			}
			var _free_num:Number = _totalMemory - System.totalMemory;			
			if (_free_num < 0) {
				PaperLogger.getInstance().log("內存 # 增加了:" + (_free_num * ( -1)) , DestroyMemory, "目前內存為:"+System.totalMemory);				
			}else {
				PaperLogger.getInstance().log("內存 # 釋放了:" + _free_num , DestroyMemory, "目前內存為:"+System.totalMemory);
			}
		}
	}

}
